<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>人员信息显示页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            margin: 0;
            padding: 20px;
        }
        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
        }
        table {
            width: 80%;
            margin: 0 auto;
            border-collapse: collapse;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        th, td {
            padding: 15px;
            text-align: center;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #4CAF50;
            color: white;
            font-weight: bold;
        }
        tr:hover {
            background-color: #f1f1f1;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 30px;
            gap: 10px;
        }
        .pagination button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
        }
        .pagination button:hover:not(:disabled) {
            background-color: #45a049;
        }
        .pagination button:disabled {
            background-color: #cccccc;
            cursor: not-allowed;
        }
        .page-info {
            text-align: center;
            margin-top: 15px;
            color: #666;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <h1>人员信息列表</h1>
    <table>
        <thead>
        <tr>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>操作 | <a href="save.html">保存</a> | <a href="/logout">退出</a></th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="person:${list}">
            <td th:text="${person.username}"></td>
            <td th:text="${person.sex}"></td>
            <td th:text="${person.age}"></td>
            <td>
                <a th:href="@{/delete.do(id=${person.id},flag='del')}" onClick="return confirm('确定删除吗？')">删除</a>
                <a th:href="@{/data.do(id=${person.id},flag='data')}">修改</a>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="pagination">
        <button id="firstPage" th:disabled="${pageNo==1}" th:onclick="|findPage(1)|">首页</button>
        <button id="prevPage" th:disabled="${pageNo==1}" th:onclick="|findPage(${pageNo - 1})|">上一页</button>
        <button id="nextPage" th:disabled="${pageNo==total}" th:onclick="|findPage(${pageNo + 1})|">下一页</button>
        <button id="lastPage" th:disabled="${pageNo==total}" th:onclick="|findPage(${total})|">尾页</button>
    </div>

    <div class="page-info" id="pageInfo">
        当前页：<span th:text="${pageNo}"></span> |
        总页数：<span th:text="${total}"></span>
    </div>

    <script>
        function findPage(pageNo) {
            window.location.href = `/show.do?pageNo=${pageNo}`;
        }
    </script>
</body>
</html>